package com.kancy.learn.rpc.rmi.zookeeper.client;

import com.kancy.learn.rpc.rmi.api.IMessageService;
import com.kancy.learn.rpc.rmi.api.entity.Message;
import com.kancy.learn.rpc.rmi.api.entity.Result;

import java.rmi.Naming;

/**
 * @author kancy
 * @version 1.0
 * @date 2019/1/31 11:03
 */
public class ZookeeperClientApplication {
    private static final ServiceConsumer serviceConsumer = new ServiceConsumer();
    public static void main(String[] args) {

        try {
            // 获取MessageService的代理对象，屏蔽传输层
            IMessageService messageService = serviceConsumer.lookup();
            Message message = new Message();
            message.setId(System.currentTimeMillis());
            message.setContext("Hi,Kancy ZooKeeper!");
            message.setBody(message.getContext().getBytes());
            Result result = messageService.processMessage(message);
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
